<!--{template common/header_simple_start}-->
<link href="static/css/common.css?{VERHASH}" rel="stylesheet" media="all">
<link href="dzz/share/images/share.css?{VERHASH}" rel="stylesheet" media="all">
<script type="text/javascript" src="static/js/jquery.leftDrager.js?{VERHASH}"></script>

<!--{template common/header_simple_end}-->
<nav class="navbar navbar-default bs-navbar-default navbar-fixed-top" role="navigation" style="margin:0;padding:0 10px;">
	<ul class="nav nav-pills tag-container nav-pills-bottomguide clearfix">
		<li>
			<a href="{DZZSCRIPT}?mod=share">{lang all}</a>
		</li>
		<li class="pull-right " style="margin:4px 0;">
			<form name="search" action="{DZZSCRIPT}" method="get">
				<input type="hidden" name="mod" value="share" />
				<div class="input-group" style="width:180px">
					<input name="keyword" type="text" class="form-control input-sm" value="$keyword" placeholder="{lang share_title}">
					<a class="input-group-addon" herf="javascript:;" onclick="this.parentNode.parentNode.submit()"><i class="glyphicon glyphicon-search"></i></a>
				</div>
			</form>
		</li>
		<li class="pull-right gray" style="margin:4px 0;line-height:30px;padding-right:10px;font-size:12px">{lang loaded}<span class="loaded-num">{eval echo count($list);}</span>{lang individual}<span class="total-num">，{lang total} $count {lang individual}</span></li>
	</ul>
</nav>
<div class="bs-container clearfix">
	<div class="bs-main-container">
		<div class="main-content clearfix">
			<!--{if !$count}-->
			<div node-type="module" class="module-share-empty text-center clearfix">
				<div class="no-result-div" style="padding-top:40px;">
					<p class="no-result-pic"><em class="shr"></em></p>
					<p class="no-result-title">{lang share_file_friend}</p>
				</div>
			</div>
			<!--{else}-->
			<div node-type="module" class="module-list-toolbar" style="display: none;">
				<div class="bar clearfix">
					<span node-type="chk" class="chk-box"> 
            	<span class="chk"></span>
					</span>
					<span class="text"> {lang checked}<span node-type="num">0</span>{lang file_number_type}</span>
					<button class="btn btn-sm btn-danger" data-key="unshare"><span>{lang cancel_share}</span> </button>
				</div>
			</div>
			<div node-type="module" class="module-list-view">
				<div node-type="wrapper" class="list-view-home">
					<div node-type="title" class="title" style="padding-right: 16px;">
						<div class="item clearfix">
							<!-- 第一列 -->
							<div node-type="title-col" data-key="name" class="col c1" style="width: 50%">
								<span node-type="chk-all" class="chk"> <span class="chk-ico"></span> </span>
								<div class="name"> <span>{lang share_typename_attach}</span> <span node-type="order-status" class="asc desc" style="visibility: hidden;"></span> </div>
							</div>
							<!-- 其他列 -->
							<div node-type="title-col" data-key="dateline" class="col" style="width: 20%;
                "> {lang share_time} <span node-type="order-status" class="asc desc" style="visibility: visible;"></span> </div>
						<div node-type="title-col" data-key="count" class="col" style="width: 9%;
                "> {lang view_count} <span node-type="order-status" class="asc desc" style="visibility: hidden;"></span> </div>
					<div node-type="title-col" data-key="size" class="col" style="width: 9%;
                "> {lang file_size} <span node-type="order-status" class="asc desc" style="visibility: hidden;"></span> </div>
				<div node-type="title-col" data-key="type" class="col" style="width: 9%;
                border-right: none;"> {lang file_type} <span node-type="order-status" class="asc desc" style="visibility: hidden;"></span> </div>
		</div>

	</div>
	<div node-type="list" class="list list-share clearfix">
		<div class="list-wrapper clearfix">
			<!--{loop $list $value}-->
			<div node-type="item" data-sid="$value[sid]" data-status="$value[status]" class="item clearfix">
				<!-- 第一列 -->
				<div class="col c1 name" style="width: 50%;" data-name="$value[title]">
					<span node-type="chk" class="chk"> <span class="chk-ico"></span></span>
					<!-- 私密分享图标 -->
					<!--{if $value[password]}--><span class="ico-private-share" title="{lang password_share}"></span><!--{/if}-->

					<div node-type="name" class="name" title="$value[title]">
						<!--{if $value[img]}--><img class="icon" src="$value[img]" /><!--{/if}-->
						<!--{if $value[status]<0}--><span node-type="name-tip" style="color: red;">($value[fstatus])</span><!--{/if}-->
						<span class="name-text-wrapper"> <span node-type="name-text"  data-href="$value[shareurl]" class="name-text enabled">$value[title]</span> </span>
					</div>

				</div>

				<!-- 其他列 -->
				<div class="col dateline" style="width: 20%" data-dateline="$value[dateline]">$value[fdateline]</div>
				<div class="col count" style="width: 9%" data-count="$value[count]">$value[count]次</div>
				<div class="col size" style="width: 9%" data-size="$value[size]">$value[fsize]</div>
				<div class="col type" style="width: 9%" data-type="$value[ftype]">$value[ftype]</div>

				<!-- 复制 -->
				<div node-type="copy-bar" class="copy-bar">
					<!--{if $value[qrcode]}-->
					<a href="javascript:;" class="qrcode glyphicon glyphicon-qrcode" title="{lang scan_code_send_mobile}" data-container="body" data-html="true" data-trigger="click" data-toggle="popover" data-placement="right" data-content="<p class='text-center'><img src='$value[qrcode]'></p>"></a>
					<!--{/if}-->
					{lang share_link}：
					<a href="$value[shareurl]" target="_blank">$value[shareurl]</a>
					<!--{if $value[password]}-->&nbsp;{lang extract_password}：$value[password]<!--{/if}-->
					&nbsp;<button class="btn btn-sm btn-default js_copy" data-clipboard-text="{eval echo $value[password]?('{lang link}:'.$value[shareurl].'  {lang password}:'.$value[password]):$value[shareurl];}" style="position:relative"><i class="glyphicon glyphicon-duplicate"></i> {lang copy}<span class="alert copy-success  alert-success hide ">{lang copy_success_paste_need_place}</span></button>
					<!--{if $value[endtime]}-->&nbsp;{lang expiration_time}：$value[fendtime]<!--{/if}-->
					<!--{if $value[times]}-->&nbsp;{lang limited_number}：$value[count] / $value[times]<!--{/if}-->
				</div>
				<!--{if $value[downurl]}-->
				<div node-type="copy-bar" class="copy-bar">
					{lang download_link}：
					<a href="$value[downurl]" target="_blank">$value[downurl]</a>
					<!--{if $value[password]}-->&nbsp;{lang extract_password}：$value[password]<!--{/if}-->
					&nbsp;<button class="btn btn-sm btn-default js_copy" data-clipboard-text="{eval echo $value[password]?('{lang download_link}:'.$value[downurl].'  {lang password}:'.$value[password]):$value[downurl];}" style="position:relative"><i class="glyphicon glyphicon-duplicate"></i> {lang copy}<span class="alert copy-success  alert-success hide ">{lang copy_success_paste_need_place}</span></button>
				</div>
				<!--{/if}-->
			</div>
			<!--{/loop}-->
			<!--{if $nextpage}-->
			<div class="more text-center clearfix" onclick="getMore(this,'$nextpage')">{lang upload_more}</div>
			<!--{/if}-->
		</div>
	</div>
</div>
</div>
<!--{/if}-->
</div>
</div>
</div>
<script type="text/javascript">
	jQuery('.left-drager').leftDrager_layout(function() {
		jQuery('.list').css('height', jQuery('.bs-main-container').outerHeight(true) - jQuery('.list-view-home .title').outerHeight(true));
	});
	jQuery('.list-share').scroll(function(e) {
		var clientHeight = jQuery('.list-share').height();
		var scrollHeight = jQuery('.list-wrapper').height();
		if(jQuery('.list-share').scrollTop() + clientHeight >= scrollHeight - 5) jQuery('.more').trigger('click');
	});

	function getMore(obj, page) {
		jQuery(obj).html('<img src="dzz/images/loading.gif">{lang loading}');
		jQuery.get('$theurl&page=' + page + '&inajax=1', function(html) {
			jQuery(obj).replaceWith(html);
			setLoadedNum();
		});
	}

	function setLoadedNum() {
		jQuery('.loaded-num').html(jQuery('.list-share .item').length);
	}
	jQuery(document).ready(function(e) {
		jQuery(document).on('mouseenter', 'div[node-type=item]', function() {
			jQuery(this).addClass('item-hover');
		});
		jQuery(document).on('mouseleave', 'div[node-type=item]', function() {
			jQuery(this).removeClass('item-hover');
		});
		jQuery(document).on('click', 'span[node-type=name-text]', function() {
			if(top._config) {
				top.OpenWindow('url', jQuery(this).data('href'), jQuery(this).html(), null, { "img": jQuery(this).closest('.name').find('img.icon').attr('src'), "name": jQuery(this).html() });
			} else {
				window.open(jQuery(this).data('href'), jQuery(this).html());
			}
		});
		jQuery('.chk[node-type=chk-all]').on('click', function() {
			jQuery(this).addClass('chked');
			jQuery('.item').each(function() {
				jQuery(this).addClass('item-active').find('span[node-type=chk]').addClass('chked');
			});
			refresh_header();
		});
		jQuery(document).on('click', '.item .chk', function() {
			
			jQuery(this).toggleClass('chked');
			jQuery(this).closest('.item').toggleClass('item-active');
			jQuery('.copy-bar').hide();
			refresh_header();
			return false;
		});
		jQuery('.module-list-toolbar .chk').on('click', function() {
			if(jQuery(this).hasClass('chked')) {
				jQuery(this).removeClass('chked');
				jQuery('.chk[node-type=chk-all]').removeClass('chked');
				jQuery('.module-list-toolbar').hide();
				jQuery('.item.item-active').each(function() {
					jQuery(this).removeClass('item-active').find('span[node-type=chk]').removeClass('chked');
					jQuery(this).find('.copy-bar').hide();
				});
			} else {
				jQuery(this).addClass('chked');
				jQuery('.item:not(.item-active)').each(function() {
					jQuery(this).addClass('item-active').find('span[node-type=chk]').addClass('chked');
				});
				var sum = jQuery('.list .item.item-active').length;
				jQuery('.module-list-toolbar').find('span[node-type=num]').html(sum);
			}
		});
		jQuery(document).on('click', 'div[node-type=item]', function(e) {
			e = e ? e : event;
			var el = jQuery(this);
			var actives = jQuery('.item-active').length;
			if(e.ctrlKey) {
				jQuery('.item-active').not(this).find('.copy-bar').hide();
			} else {
				jQuery('.item-active').not(this).each(function() {
					jQuery(this).removeClass('item-active').find('span[node-type=chk]').removeClass('chked')
						.end().find('.copy-bar').hide();
				});
			}
			if(el.hasClass('item-active') && (actives == 1 || e.ctrlKey)) {
				el.removeClass('item-active').find('span[node-type=chk]').removeClass('chked');
				el.find('.copy-bar').hide();
			} else {
				el.addClass('item-active').find('span[node-type=chk]').addClass('chked');
				if(parseInt(el.data('status')) > -1) el.find('.copy-bar').show();
			}
			refresh_header();
		});
		var client = new ZeroClipboard(jQuery('.js_copy'));
		client.on("load", function(client) {
			client.on("complete", function(client, args) {
				var self = this;
				jQuery(this).parent().find('.copy-success').removeClass('hide');
				window.setTimeout(function() {
					jQuery(self).parent().find('.copy-success').addClass('hide');
				}, 1000);
			});
		});
		jQuery('.title .item .col[node-type=title-col]').on('click', function() {
			var el = jQuery(this);
			el.find('.asc').css('visibility', 'visible').toggleClass('desc');
			el.siblings().find('.asc').css('visibility', 'hidden');
			item_sort(el.data('key'), el.find('.asc').hasClass('desc') ? 'desc' : 'asc');
		});
		jQuery('button[data-key=unshare]').on('click', function() {
			var msg = '{lang cancel_share_state}';
			showDialog(msg, 'confirm', '{lang confirm_cancel_share}', share_delete, 1)
		});
		jQuery(document).on('click', '.qrcode', function() {
			//jQuery(this).popover('toggle');
			return false;
		});
		/*jQuery(document).on('mouseleave','.qrcode,.qrcode-zoom',function(){
		  jQuery(this).removeClass('qrcode-zoom');
	 });*/
		jQuery('[data-toggle="popover"]').popover();

		setLoadedNum();
	});

	function item_sort(key, order) {

		var sarr = new Array();
		jQuery('.list-share .item').each(function(index) {
			sarr.push((jQuery(this).find('.col.' + key).data(key)) + '____' + index);
		});
		if(key == 'dateline' || key == 'size') {
			sarr = sarr.sort(function(a, b) {
				return(parseInt(a) - parseInt(b));
			});
		} else {
			sarr = sarr.sort();
		}
		var frage = document.createDocumentFragment();
		var list = jQuery('.list-share .item');
		if(order == 'desc') {
			for(var i = sarr.length - 1; i >= 0; i--) {
				var index = sarr[i].split('____')[1];
				frage.appendChild(list.get(index));
			}
		} else {
			for(var i = 0; i < sarr.length; i++) {
				var index = parseInt(sarr[i].split('____')[1]);
				frage.appendChild(list.get(index));
			}
		}
		var page = jQuery('.list-wrapper .more').clone();
		jQuery(frage).appendTo(jQuery('.list .list-wrapper').empty());
		page.appendTo('.list .list-wrapper');
	}

	function share_delete() {
		var sids = new Array();
		jQuery('.list .item-active').each(function() {
			sids.push(jQuery(this).data('sid'));
		});
		jQuery.post(DZZSCRIPT + '?mod=share&op=ajax&do=delete', { "sids": sids }, function(json) {
			if(json.msg == 'success') {
				showmessage('{lang cancel_share_success}', 'success', 2000, 1);
				jQuery('.list .item-active').remove();
				refresh_header();
			} else {
				showmessage(json.error, 'danger', 3000, 1);
			}
		}, 'json');
	}

	function refresh_header() {
		var sum = jQuery('.list .item.item-active').length;
		var tsum = jQuery('.list .item').length;
		if(sum > 0) {
			jQuery('.module-list-toolbar').find('span[node-type=num]').html(sum).end().show();
			if(sum == tsum) {
				jQuery('.module-list-toolbar').find('.chk').addClass('chked');
			} else {
				jQuery('.module-list-toolbar').find('.chk').removeClass('chked');
			}
		} else {
			jQuery('.module-list-toolbar').hide();
			jQuery('.chk[node-type=chk-all]').removeClass('chked');
		}
		jQuery('[data-toggle="popover"]').popover('hide');
	}
</script>
<!--{template common/footer_simple}-->
<script type="text/javascript" src="static/js/ZeroClipboard/ZeroClipboard.min.js?{VERHASH}"></script>
<script src="static/bootstrap/js/bootstrap.min.js?{VERHASH}"></script>